<style>
.image-placeholder
{
	max-width:400px;
	}
	
.doc {
overflow: auto;

    border: 1px solid black;
    float: left;
    height: 500px;
}
</style>

<div class="users view">
	<div class="row">
		<div class="col-md-12">
			<div class="page-header">
				<h1><?php  echo Inflector::humanize(__($user['User']['user_role']));
						$this->set('title_for_layout', Inflector::humanize($user['User']['user_role']));

				 ?></h1>
			</div>
		</div>
	</div>

	<div class="row">

    <?php echo $this->element('admin-menu'); ?>

		<div class="col-md-9">			
			<table cellpadding="0" cellspacing="0" class="table table-striped">
				<tbody>
				<tr>
		<th><?php echo __('Id'); ?></th>
		<td>
			<?php echo h($user['User']['id']); ?>
			&nbsp;
		</td>
</tr>
<tr>
		<th><?php echo __('First Name'); ?></th>
		<td>
			<?php echo h($user['User']['first_name']); ?>
			&nbsp;
		</td>
</tr>
<tr>
		<th><?php echo __('Last Name'); ?></th>
		<td>
			<?php echo h($user['User']['last_name']); ?>
			&nbsp;
		</td>
</tr>
<tr>
		<th><?php echo __('Email'); ?></th>
		<td>
			<?php echo h($user['User']['email']); ?>
			&nbsp;
		</td>
</tr>
<tr>
		<th><?php echo __('Image'); ?></th>
		<td>
			<?php 
                    if(!empty($user['User']['image'])){
                    $image	=	'/files/user/'.$user['User']['image'];
                    echo $this->Html->image($image,array('alt'=>'',"class"=>"image-placeholder"));
                    }
                    else
                    {
                        echo ' <img src="" class="image-placeholder" id="agent-image" alt="Image"/>';
                    }
                     ?>    
			&nbsp;
		</td>
</tr>
					<?php 
                    if(!empty($user['User']['documents'])){ ?>
<tr>
		<th><?php echo __('Documents'); ?></th>
		<td>
					<?php 
                    if(!empty($user['User']['documents'])){
                    $doc	=	'/files/user_doc/'.$user['User']['documents']; 
					$file_parts = pathinfo($doc);
								if(strtolower($file_parts['extension'])=='pdf'){
								?>
								<object data="<?php echo $this->Html->url($doc); ?>" type="application/pdf" width="100%" height="500">
								alt : <a href="<?php echo $this->Html->url($doc); ?>">PDF Documents</a>
								</object>
								<?php
							}
							else
							{
								echo '<div  class="doc">';
							echo $this->Html->image($doc,array('alt'=>'',"class"=>"image-doc"));
							echo '</div>';
							}
					echo $this->Html->link('<b>Docmuents Download</b>', array('action' => 'download', $user['User']['id']), array('escape' => false));
					 }
                    else
                    {
                        echo ' <img src="" class="image-placeholder" id="agent-image" alt="documents"/>';
                    }
                     ?>                  
			&nbsp;
		</td>
</tr>
<?php  } ?>
<tr>
		<th><?php echo __('Mobile Phone'); ?></th>
		<td>
			<?php echo h($user['User']['mobile_phone']); ?>
			&nbsp;
		</td>
</tr>
<tr>
		<th><?php echo __('Work Phone'); ?></th>
		<td>
			<?php echo h($user['User']['work_phone']); ?>
			&nbsp;
		</td>
</tr>
<tr>
		<th><?php echo __('Facebook'); ?></th>
		<td>
			<?php echo h($user['User']['facebook']); ?>
			&nbsp;
		</td>
</tr>
<tr>
		<th><?php echo __('Twitter'); ?></th>
		<td>
			<?php echo h($user['User']['twitter']); ?>
			&nbsp;
		</td>
</tr>
<tr>
		<th><?php echo __('Google Plus'); ?></th>
		<td>
			<?php echo h($user['User']['google_plus']); ?>
			&nbsp;
		</td>
</tr>
<tr>
		<th><?php echo __('Linkedin'); ?></th>
		<td>
			<?php echo h($user['User']['linkedin']); ?>
			&nbsp;
		</td>
</tr>
<tr>
		<th><?php echo __('Description'); ?></th>
		<td>
			<?php echo h($user['User']['description']); ?>
			&nbsp;
		</td>
</tr>
<tr>
		<th><?php echo __('Created'); ?></th>
		<td>
			<?php echo $this->Time->format($user['User']['created'], '%B %e, %Y %I:%M %p'); 
						echo '<br/>';
						echo '('.$this->Time->timeAgoInWords(
   $user['User']['created'],
  array('format' => 'F jS, Y, H', 'end' => '+1 year',)
).')';

			?>
			&nbsp;
		</td>
</tr>
<tr>
		<th><?php echo __('Modified'); ?></th>
		<td>
			<?php echo $this->Time->format($user['User']['modified'], '%B %e, %Y %I:%M %p'); 
						echo '<br/>';
						echo '('.$this->Time->timeAgoInWords(
   $user['User']['modified'],
  array('format' => 'F jS, Y, H', 'end' => '+1 year',)
).')';

			
			?>
			&nbsp;
		</td>
</tr>
<tr>
		<th><?php echo __('Active'); ?></th>
		<td>
			<?php if($user['User']['active']==1) echo 'Active'; else echo 'Inactive'; ?>
			&nbsp;
		</td>
</tr>
<tr>
		<th><?php echo __('Approved'); ?></th>
		<td>
			<?php if($user['User']['approved']==1) echo 'approved'; else echo 'Not approved'; ?>
			&nbsp;
		</td>
</tr>
<tr>
		<th><?php echo __('Edit'); ?></th>
		<td>
							<?php echo $this->Html->link('<span class="glyphicon glyphicon-edit"></span>', array('action' => 'edit', $user['User']['id']), array('escape' => false)); ?>
			&nbsp;
		</td>
</tr>
				</tbody>
			</table>

<?php if(isset($users) and !empty($users)) { ?>
<div class="row">
<hr />
<br />
<br />
	<h1><?php echo __('Related Agents');?></h1>

<table cellpadding="0" cellspacing="0" class="table table-striped">
				<thead>
					<tr>
						<th><?php echo $this->Paginator->sort('first_name'); ?></th>
						<th><?php echo $this->Paginator->sort('last_name'); ?></th>
						<th><?php echo $this->Paginator->sort('email'); ?></th>
						<th><?php echo $this->Paginator->sort('created'); ?></th>
						<th><?php echo $this->Paginator->sort('user_role'); ?></th>
						<th><?php echo $this->Paginator->sort('active'); ?></th>
						<th class="actions"></th>
					</tr>
				</thead>
				<tbody>
				<?php foreach ($users as $user): ?>
					<tr>
						<td><?php echo h($user['User']['first_name']); ?>&nbsp;</td>
						<td><?php echo h($user['User']['last_name']); ?>&nbsp;</td>
						<td><?php echo h($user['User']['email']); ?>&nbsp;</td>
						<td><?php echo h($user['User']['created']); ?>&nbsp;</td>
						<td><?php echo Inflector::humanize($user['User']['user_role']); ?>&nbsp;</td>
						<td><?php if($user['User']['active']==1) echo 'Active'; else echo  'In-Active' ?>&nbsp;</td>
						<td class="actions">
							<?php echo $this->Html->link('<span class="glyphicon glyphicon-search"></span>', array('action' => 'view', $user['User']['id']), array('escape' => false)); ?>
							<?php echo $this->Html->link('<span class="glyphicon glyphicon-edit"></span>', array('action' => 'edit', $user['User']['id']), array('escape' => false)); ?>
							<?php echo $this->Form->postLink('<span class="glyphicon glyphicon-remove"></span>', array('action' => 'delete', $user['User']['id']), array('escape' => false), __('Are you sure you want to delete # %s?', $user['User']['id'])); ?>
						</td>
					</tr>
				<?php endforeach; ?>
				</tbody>
			</table>
            <?php echo $this->element('admin-paginate'); ?>
            </div>
			<?php } ?>
            
		</div><!-- end col md 9 -->

	</div>
</div>

